import java.util.concurrent.locks.LockSupport;

public class runPack {
    private static final sun.misc.Unsafe UNSAFE = null;
    private void LockSupport(){};
    public static void pack(){
        UNSAFE.park(false,0L);
    }
    public static void unpack(Thread thread){
        if(thread!=null){
            UNSAFE.unpark(thread);
        }
    }
    public static void packUntil(long deadline){
        UNSAFE.park(true,deadline);
    }
    public static void main(String[] args) {
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for(int i=0;i<10;i++){
                    System.out.println(Thread.currentThread().getId()+",i="+i);
                    if(i==5){
                        System.out.println(Thread.currentThread().getId()+"开始等待。。。");
                        LockSupport.park();
                    }
                }
            }
        });

        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getId()+"running...");
                System.out.println(Thread.currentThread().getId()+"，发送解锁通知...");
                LockSupport.unpark(t1);
            }
        });
        t1.start();
        try{
            Thread.sleep(1000);
        }catch(Exception e){
            e.printStackTrace();
        }
        System.out.println(t1.getId()+"状态"+t1.getState());
        t2.start();

    }
}
